package com.wn.controller;

import com.fasterxml.jackson.databind.ser.Serializers;
import com.wn.pojo.Order;
import com.wn.service.IOrderService;
import com.wn.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yellow docker
 * @since 2023-06-28
 */
@RestController
@RequestMapping("/order")
public class OrderController extends BaseController {

    @Autowired
    private IOrderService orderService;

    @PostMapping("{courseId}")
    public Result addOrder(@PathVariable("courseId")String courseId){
        //添加订单
        Order order = orderService.addOrder(courseId);
        return toDataResult(order);
    }

    @GetMapping("{orderId}")
    public Result findOrderById(@PathVariable("orderId")String orderId){
        //查询订单
        Order order = orderService.getById(orderId);
        return toDataResult(order);
    }
}
